<template>
  <router-link v-if="type===1" class="cate-item" tag="div" :to="`/detail?id=${id}`">
    <div class="cate-item-img">
      <img :src="image" alt="">
    </div>
      <div class="cate-item-text" v-if="type === 1">
        <p>{{ title }}</p>
        <div class="couponValue">
          <span>{{ couponValue }}</span>
          <span>包邮</span>
        </div>
        <div class="info">
          <span>￥{{ price | toFix2 }}</span>
          <span>{{ saleNum | over10000 }}人已买</span>
        </div>
      </div>
  </router-link>
  <router-link v-else class="cate-item" tag="div" :to="`/listPage?url=${url}`">
    <div class="cate-item-img">
      <img :src="image" alt="">
    </div>
  </router-link>
</template>

<script>
export default {
  name: 'VueCateList',
  props: ['id', 'image', 'title', 'price', 'saleNum', 'type', 'couponValue', 'url']
}
</script>

<style lang="scss" scoped>
.cate-item {
    &-img {
      width: 100%;
      img {
        width: 100%;
        border: none;
        vertical-align: top;
      }
    }
    &-text {
      width: 100%;
      font-size: 12px;
      color: #666;
      p {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        padding: 5px;
      }
      .info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 5px;
        span:first-child {
          color: red;
          font-size: 14px;
        }
      }
      .couponValue {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 5px;
        span:first-child {
          display: block;
          background: brown;
          color: white;
          padding: 0px 2px;
        }
      }
    }
  }
</style>
